package com.example.springbasic.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/uwp")
public class GetController {

    @Value("${deviceName}")
    private String deviceName;
    // 总结：1、需要用${} 把自定义的key包裹起来；2、${}主要用来加载外部配置值

    @Value(value = "${app:wechat}")
    private String app;

    @GetMapping("/{tag}")
    String getUrlWithParams(@PathVariable("tag") String id, @RequestParam(value = "token",defaultValue = "66") String sid){
        System.out.println("配置文件值："+ deviceName + app);
        return id+sid;
    }

    @GetMapping("/{city}/{year}")
    String getUrlWithParmas(@PathVariable int year,
                            @PathVariable String city,
                            @RequestParam(defaultValue = "支出") String description,
                            @RequestParam(defaultValue = " 1000") int money){
        return "{"+year+"}年{"+city+"}年{"+description+"}收入{"+money+"}元！";
    }
}
